package easy

func ModifiedMatrix(matrix [][]int) [][]int {
	m := len(matrix)
	n := len(matrix[0])

	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			if matrix[i][j] == -1 {
				maxVal := -1
				for k := 0; k < m; k++ {
					maxVal = max(maxVal, matrix[k][j])
				}
				matrix[i][j] = maxVal
			}
		}
	}
	return matrix
}
